/*-----------------------------------------------------------------------------*
																			   
 TITLE: 				Does citizen participation in budget allocation pay? A 
						survey experiment on political trust and participatory 
						governance.
 CORRESPONDING AUTHOR:	Carlos Scartascini (carlossc@iadb.org)
 CODE AUTHOR:			Susana Otálvaro-Ramírez (susanaot@iadb.org)
						Martin Ardanaz (martina@iadb.org)
 
 DATE CREATED: 			January 17, 2021
 LAST MODIFIED: 		April 27, 2022
 SOFTWARE VERSION:		Stata 17
																			   
 DESCRIPTION: 			Summary stats, regressions, graphs and robustness checks
*/

/*				
********************************************************************************
*									INDEX
********************************************************************************

			
		1. MAIN TABLES AND GRAPHS 
			a. Table 1.  Descriptive Statistics and Balance - control variables
			b. Table 2.  Treatment Effects on Perceptions about the City Government
			c. Table 3.  Treatment Effects on Perceived trustworthiness of government members
			d. Table 4.  Treatment Effects on Citizenry Perceptions and Preferences for participation
			e. Figure 1. Previous Knowledge of the BA Elige Initiative
			f. Figure 2. Components of the Perception of the Government Index (control group)
			g. Figure 3. Trust in Institutional Agents (control group)
			h. Figure 4. Citizens participation perceptions and preferences (control group)
			i. Figure 5. Heterogeneous effects on Perceptions of the Government - Perceived Quality of the Goverment, Collective action capacity and previous knowledge
			j. Figure 6. Heterogeneous effects on Perceptions of the Government - Perceived Quality of the Goverment, Collective action capacity and previous knowledge
			
		2. APPENDIX
			A. TABLES AND GRAPHS 
				a. Figure A2. Recruitment timeline by treatment assignment
				b. Table A1. Multiple Hypothesis Testing results - Balance 
				c. Table A2. Censored Sample - Balance 
				d. Table A3. Descriptives Statistics of Dependent Variables (control group)
				e. Table A4. Principal Component Analysis
				f. Table A5. Generalized Ordered Logit
				g. Table A6. Estimated bounds following Oster (2019)
				h. Table A7. Main results controlling for unbalanced characteristics
				i. Table A8. Main results using censored samples
				j. Table A9. Perceived trustworthiness of different agents. 

			B. HETEROGENEOUS EFFECTS 
				a. Figure B1. Correlation between previous knowledge of the program and perceived quality of the government 
				b. Table B1. Heterogeneous effects on Perceptions about the government - perceived quality of the government, coll action and prev. knowledge
				c. Table B2. Heterogeneous effects on Trust in Institutional agents - perceived quality of the government, coll action and prev. knowledge
				d. Table B3. Heterogeneous effects on Participation perceptions and preferences - perceived quality of the government, coll action and prev. knowledge
				e. Table B4. Heterogeneous effects of previous knowledge of the initiative
				
			C. POWER ANALYSIS
				a. Table C1. Power - Dimensions and components
				b. Table C2. Power - Perceptions and preferences
		
*-----------------------------------------------------------------------------*/

drop _all
clear all
clear mata
clear matrix
set more off
ssc install rsource, replace

*---------------------------------------*
* 0. PRELIMINARY SETTING 				*
*---------------------------------------*
if 1==1{
** Directories 
* Susana 
if "`c(username)'"=="SUSANAOT" {
	di in red "Susana Otalvaro"
	glo dir 	= "C:\Users\SUSANAOT\OneDrive - Inter-American Development Bank Group\SUSANAOT\5_BAElige\replication"
	glo data	= "$dir\data"
	glo dofiles = "$dir\do-files"
	glo outp	= "$dir\results" 
	
	*cap n mkdir "$outp\tables"
	glo results = "$outp\tables"
}

* Martin
if "`c(username)'"=="martina" {
	di in red "Martin Ardanaz"
	glo dir 	= "C:\Users\martina\Inter-American Development Bank Group\Otalvaro Ramirez, Susana - 5_BAElige"
	glo data 	= "$dir\data"
	glo dofiles = "$dir\do-files"
	glo outp	= "$dir\results" 
	
	*cap n mkdir "$outp\tables"
	glo results = "$outp\tables"
}

* Carlos
if "`c(username)'"=="carlossc" {
	di in red "Carlos Scartascini"
	glo dir 	= 
	glo data 	= "$dir\Data\1. Data"
	glo dofiles = "$dir\do-files"
	glo outp	= "$dir\results" 
	glo results = "$outp\tables"
}
}

use "$data\baelige1.dta", replace 

glo balance 	"gender age Secondary College employed unemployed ABC1_nse HasCC HasInt HasMed HasCar Gov_Q_C know_baew1 know_baew2 know_baew3 know_baew4 TrustOthers_D CollAction_D Cit_Part_D Inc_Reg_Burden duration"
glo Treatments 	"T1 T2"
glo controls_unb "gender age unemployed HasCC Gov_Q_C"
glo controls_rel "i.knows_bae1 TrustOthers3cat CollAction Cit_Part"
glo controls_rel2 "TrustOthers3cat CollAction Cit_Part"
glo	inst_trust 	"P_Politicians_D P_Public_Servants_D C_Politicians_D C_Public_Servants_D"
glo	perception 	"zo_Gov_Capable zo_Gov_Best zo_Gov_Budget  zo_Gov_Neigh zo_Gov_Helps zo_Gov_ICare zo_Gov_Honesty"
glo participat 	"Gov_ListensCat Neighb_Decide"
glo original 	"Gov_Capable Gov_Best Gov_Budget  Gov_Neigh Gov_Helps Gov_ICare Gov_Honesty"

*---------------------------------------*
* 1. MAIN TABLES AND GRAPHS 			*
*---------------------------------------*
if 1==0{
* a. Table 1.  Descriptive Statistics and Balance - control variables
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
	
cap texdoc close
	texdoc init "$results\Table1", replace force
	tex \begin{table}[H]
	tex \centering
	tex \scriptsize		
	tex \caption{Summary statistics and balance\label{tab:Descriptives}}
	tex \begin{tabular}{l*{6}{c}}			
	tex \toprule
	tex 					& Sample  & Control 		& \multicolumn{2}{c}{Diff wrt. Control}	& \multicolumn{1}{c}{Wald test} & Sample \\
	tex \textbf{Variable}  	& Average & (av. \& s.e.) & T1 	& T2 & T1=T2 & Size \\
	tex \midrule
	
	foreach v in $balance{
	disp in red "`v'"
		
		su `v'
		loc mean`v'	: di %7.3f r(mean)
		loc sd`v' 	: di %7.3f r(sd)
		
		reg `v' $Treatments, vce(hc3) 
		loc meT0`v'	: di %7.3f _b[_cons]
		loc seT0`v'	: di %7.3f _se[_cons]
		loc diT1`v' : di %7.3f _b[T1]
		loc seT1`v' : di %7.3f _se[T1]
		loc diT2`v' : di %7.3f _b[T2]
		loc seT2`v' : di %7.3f _se[T2]
		
		loc tbef1 = _b[T1]/_se[T1]
		loc pbef1 : di %7.3f 2*ttail(e(df_r),abs(`tbef1'))	
		loc staru1 = ""
		if ((`pbef1' < 0.1))  loc staru1 = "*" 
		if ((`pbef1' < 0.05)) loc staru1 = "**" 
		if ((`pbef1' < 0.01)) loc staru1 = "***" 
		
		loc tbef2 = _b[T2]/_se[T2]
		loc pbef2 : di %7.3f 2*ttail(e(df_r),abs(`tbef2'))	
		loc staru2 = ""
		if ((`pbef2' < 0.1))  loc staru2 = "*" 
		if ((`pbef2' < 0.05)) loc staru2 = "**" 
		if ((`pbef2' < 0.01)) loc staru2 = "***" 
		
		test T1=T2
		loc t1t2`v'	  : di %7.3f r(p)
		
		loc n`v' : di %7.0f e(N)
		
		tex \parbox[l]{4.3cm}{ `:variable label `v''} 	& `mean`v'' & `meT0`v'' 		& `diT1`v''`staru1' & `diT2`v''`staru2' 	& `t1t2`v'' 			& `n`v''\\
		tex  & [`sd`v''] &  (`seT0`v'') 		& (`seT1`v'')	& (`seT2`v'') 	 &			  & 	  \\
	}	
	tex \addlinespace[2pt] 
	tex \bottomrule
	tex \addlinespace[2pt]
	tex \multicolumn{7}{c}{\footnotesize{\begin{minipage}{0.95\textwidth}\textit{Notes:} Each row shows statistics for a different observable variable we have. Column [1] shows the sample average and the standard deviation in parenthesis for the control group -in this case, individuals in T0. Columns [2]-[3] show the regression coefficient and the standard error in parentheses corresponding to OLS regressions -observable is the dependent variable and the treatment variables are the independent ones (T1-T2). Column [4] shows the p-value of a Wald test of equality of coefficients. Column [5] shows the sample size for each regression. \textit{Gender} is a binary variable that takes the value of one when the respondent is a woman. \textit{Age} is a continuous variable from 18 to 100 years. \textit{College} takes the value of one when the individual has at least college, and \textit{High school} is read in the same way. \textit{Employed} and \textit{Unemployed} are binary variables for those who have full-time employment or work in their house and those who are looking for a job at the time of the survey, respectively. \textit{Socio-economic level (High)} is a binary variable for those with the highest category in socio-economic level. \textit{Perceived Quality of Governm.} is self-explanatory and takes values between 1 and 10, in which the lowest value reflects a very bad score while the greatest an excellent score. \textit{First exposure to ``Compromisos''} is a binary variable and takes the value one if the participant has not ever listened about the ``Compromisos'' policy. \textit{Trust Others} is a binary variable that takes the value of one when participants indicate that others are reliable or very reliable. \textit{Collective Action} is a dummy variable that indicates whether participants answer \textsc{Very likely or likely} or not to the following question \textit{Suppose there is a problem in your neighborhood for which you would like to find a solution and you decide to petition the city government. How likely do you think it is that the neighborhood where you live will be able to collect 500 signatures that support said petition?} Standard errors are robust.  *** p\textless 0.01, ** p\textless 0.05, * p\textless 0.1.\end{minipage}}}
	tex \end{tabular}
	tex \end{table}
	texdoc close	
}

* b. Table 2.  Treatment Effects on Perceptions about the City Government
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
** Multinomial propensity score matching (McCaffrey et al., 2021)
// Remember to change the directory in the matching.R script before running the code
if "`c(os)'"=="MacOSX" | "`c(os)'"=="UNIX" {
    rsource using "$dofiles\matching.R", rpath("/usr/local/bin/R") roptions(`"--vanilla"')
}
else {
    rsource using "$dofiles\matching.R", rpath(`"C:\Program Files\R\R-4.0.0\bin\R.exe"') roptions(`"--vanilla"')
	*shell "C:/Program Files/R/R-4.0.0/bin/R.exe" --vanilla <"$dofiles\matching.R"
}
 
** Main results 
if 1==1{	
use "$data/data.dta", clear
reg STD_Gov_PCA T1 T2 $controls_unb, vce(hc3)
test T1=T2 
loc p = r(p)
outreg2 using "$results\Table2", replace tex keep(T1 T2) label addstat(Wald test, `p') addtext(Unbalanced controls, Yes, Political controls, No, Commune FE, No, MNPS, No) dec(3) addnote("\scriptsize{\begin{minipage}{\textwidth} \textit{Notes:} Dependent variables are constructed using a PCA method, and standardized with mean zero and standard deviation one. Columns (1) to (4) incorporate controls and commune fixed effects progressively. Columns (5) and higher display the results of an Inverse Probability Weighting Model, èxploting the weights obtained from the Multinomial Propensity Score Matching. Control variables include those found unbalanced after treatment assignment (gender, age, unemployment, having credit card) and those directly related to the political perceptions (perceived quality of the government, collective action capacity, importance of citizens participation in decision-making and previous knowledge of the initiative). Robust standard errors presented in parentheses *** p\textless 0.01, ** p\textless 0.05, * p\textless 0.1\end{minipage}}")


reg STD_Gov_PCA T1 T2 $controls_unb $controls_rel, vce(hc3)
test T1=T2 
loc p = r(p)
outreg2 using "$results\Table2", append tex label addstat(Wald test, `p') keep(T1 T2 Gov_Q_C 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, No, MNPS, No) dec(3)

reg STD_Gov_PCA T1 T2 $controls_unb $controls_rel i.Comuna, vce(hc3)
test T1=T2 
loc p = r(p)
outreg2 using "$results\Table2", append tex label addstat(Wald test, `p') keep(T1 T2 Gov_Q_C 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes, MNPS, No) dec(3)


svyset idiso [pweight=w_es]
svy: reg STD_Gov_PCA T1 T2 $controls_unb $controls_rel i.Comuna
lincom T2-T1
loc p = r(p)
outreg2 using "$results\Table2", append tex label addstat(Wald test, `p') keep(T1 T2 Gov_Q_C 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes, MNPS, Yes) dec(3)

foreach outcome in STD_Competence STD_Benevolence STD_Honesty{
	svy: reg `outcome' T1 T2 $controls_unb $controls_rel i.Comuna
	lincom T2-T1
	loc p = r(p)
	outreg2 using "$results\Table2", append tex label addstat(Wald test, `p') keep(T1 T2 Gov_Q_C 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes, MNPS, Yes) dec(3)
}
}
}

* c. Table 3. Trustworthiness perception of politicians and public servants
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
su STD_Trustworthy if Treatment==0
loc meanTrustworthy = r(mean)
svy: reg STD_Trustworthy T1 T2 $controls_unb $controls_rel i.Comuna
lincom T2-T1
loc p = r(p)
outreg2 using "$results\Table3", replace tex label addstat(Wald test, `p', Control mean, `meanTrustworthy') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) dec(3) addnote("\scriptsize{\begin{minipage}{\textwidth} \textit{Notes:} All estimations use a MNPS matching technique to make treatment groups more comparable, given the balance issue found in Table \ref{tab:balance}. Column (1) presents the results on a standardized trust measure ("Is the city government trustworthy?") to make it comparable to standardized measures of competence, benevolenceand the overall index, which refers to an indirect measure of trustworthiness following \citet{grimmelikhuijsen_linking_2012}. We do not include the "it is trustworthy" component in the estimation of the global index.  Given that levels of agreement ranged from 1 to 7, we normalized them on a scale of zero to one to make it comparable to the results of dummy variables in the case of trust in specific members of the government: politicians and public servants. It is therefore what we call normalized trust in column (2). Columns (3) to (6) presents the results on trust in government members (politicians and public servants), following \citet{Keefer2018}. Control variables include those found unbalanced after treatment assignment (gender, age, unemployment, having credit card) and those directly related to the political perceptions (perceived quality of the government, collective action capacity, importance of citizens participation in decision-making and previous knowledge of the initiative). Robust standard errors presented in parentheses *** p\textless 0.01, ** p\textless 0.05, * p\textless 0.1\end{minipage}}")

su zo_Gov_Trustworthy if Treatment==0
loc meanTrustworthy = r(mean)
svy: reg zo_Gov_Trustworthy T1 T2 $controls_unb $controls_rel i.Comuna
lincom T2-T1
loc p = r(p)
outreg2 using "$results\Table3", append tex label addstat(Wald test, `p', Control mean, `meanTrustworthy') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) dec(3)

foreach outcome in P_Politicians_D C_Politicians_D P_Public_Servants_D C_Public_Servants_D{
	su `outcome' if Treatment==0
	loc mean`outcome' = r(mean)
	svy: reg `outcome' T1 T2 $controls_unb $controls_rel i.Comuna
	lincom T2-T1
	loc p = r(p)
	outreg2 using "$results\Table3", append tex label addstat(Wald test, `p', Control mean, `mean`outcome'') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) dec(3)
}
}

* d. Table 4. Citizenry perception of participation 
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
su Gov_Listens_D1 if Treatment==0
loc mean = r(mean)
svy: reg Gov_Listens_D1 T1 T2 $controls_unb $controls_rel i.Comuna
lincom T2-T1
loc p = r(p)
outreg2 using "$results\Table4", replace tex label addstat(Wald test, `p', Control mean, `mean') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) dec(3) addnote("\scriptsize{\begin{minipage}{\textwidth} \textit{Notes:} All estimations use a MNPS matching technique to make treatment groups more comparable, given the balance issue found in Table \ref{tab:balance}. They also include controls and commune fixed effects. Column (1) presents dichotomous version of a categorical variable that asks participants how likely is it that the government would listen to a neighbors petition if filed, it takes the value of 1 if the respondent indicated that she thinks it is very likely, and zero otherwise. Column (2) takes the value of 1 when people indicated they would prefer neighbors to make decisions over investments rather than public officials, and zero if the opposite was true. Control variables include those found unbalanced after treatment assignment (gender, age, unemployment, having credit card) and those directly related to the political perceptions (perceived quality of the government, collective action capacity, importance of citizens participation in decision-making and previous knowledge of the initiative). Standard errors presented in parentheses *** p\textless 0.01, ** p\textless 0.05, * p\textless 0.1\end{minipage}}")

su Neighb_Decide if Treatment==0
loc mean = r(mean)
svy: reg Neighb_Decide T1 T2 $controls_unb $controls_rel i.Comuna
lincom T2-T1
loc p = r(p)
outreg2 using "$results\Table4", append tex label addstat(Wald test, `p', Control mean, `mean') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) dec(3)
}

* e. Figure 1. Previous Knowledge of the BA Elige Initiative
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
use "$data\baelige1.dta", clear

if 1==1{
hist knows_bae1, color(gs11) lcolor(black) percent bin(4) addlabels xlabel(3.65 "BAE and web" 2.9 "BAE or web" 2.15 "BAE or web" 1.35 "Knows neither", labsize(vsmall)) ylabel(,labsize(small)) ytitle("Percentage", size(small)) xtitle("") title(" ", size(small)) xscale(range(0.8 4.3) noextend) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=8 b=6)) name(Fig1, replace) text(-3 1.95 "Has heard of", place(e) just(left) size(small)) text(-3 3.12 "Knows", place(e) just(left) size(small)) 
graph display Fig1, ysiz(9) xsiz(16)
graph export "$outp\figures\Figure1.pdf", as(pdf) replace
} 

* f. Figure 2. Components of the Perception of the Government Index (control group)
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
mat C = J(`: word count $perception',2,.)
mat colname C = "Control" "Max"

loc i 0 
foreach v in $perception{
	loc ++i 
	su `v' if Treatment==0
	mat C[`i',1]=r(mean)
	mat C[`i',2]=r(max)	
}

preserve
	clear 
	svmat C, names(col)
	gen id = _n 

	la def depen 1 "Capable" 2 "Best for the city" 3 "Spends budget aprop." 4 "Acts in neig. interests" 5 "Helps the needed" 6 "Pursues beneficial prog." 7 "Transparent"
	
	la val id depen
	
	format Control %4.2f
	
tw 	(bar Max id, color(none) lcolor(black) lwidth(0.3) horizontal) ///
	(bar Control id, color(gs11) horizontal) ///
	(scatter id Control , msymbol(none) mlabel(Control) mlabpos(9) mlabcolor(black)) ///
	, ylabel(1(1)7, valuelabel labsize(small)angle(horizontal)) xlabel(0(0.2)1, labsize(small) format(%4.2f)) ysc(reverse) ///
	legend(off) ///
	ytitle("") xtitle("Standardized responses [0,1]", size(small)) ///
	graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=25 r=5 b=5)) text(0.9 -0.75 "Competence", place(e) just(left)) text(3.9 -0.75 "Benevolence", place(e) just(left)) text(6.9 -0.75 "Honesty", place(e) just(left)) text(0.4 -0.8 "------------------------------------------------", place(e) just(left)) text(3.4 -0.8 "------------------------------------------------", place(e) just(left)) text(6.4 -0.8 "------------------------------------------------", place(e) just(left)) text(7.4 -0.8 "------------------------------------------------", place(e) just(left))
	
graph export "$outp\figures\Figure2.pdf", as(pdf) replace
restore
}

* g. Figure 3. Trust in Institutional Agents (control group)
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
mat C = J(`: word count $inst_trust',1,.)
mat colname C = "Control" 

loc i 0
foreach v of global inst_trust{
	loc ++i
	su `v' if Treatment==0
	mat C[`i',1]=r(mean)
}

preserve
clear 
svmat C, names(col)
gen id = _n 

la def dum 1 "Politicians" 2 "Public Servants" 3 "Politicians" 4 "Public Servants" 
la val id dum

gen 	ag = 1 in 1/2
replace ag = 2 in 3/4

la def ag 1 "Keep their promises" 2 "Care about people" 
la val ag ag

format Control %4.2f

tw 	(bar Control id, color(gs11)) (scatter Control id, msymbol(none) mlabel(Control) mlabpos(6)), xlabel(, valuelabel labsize(small)) ylabel(0(0.2)0.6, angle(horizontal) labsize(small)format(%4.1f)) legend(order(1 "Control") pos(12) size(small)) xtitle("") ytitle("It is likely that... (%)", size(small))  title(" ", size(medsmall)) text(-0.15 1.5 "Keep their promises", place(c)size(small)) text(-0.15 3.5 "Care about people like you", place(c)size(small)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=5 b=10)) name(`t', replace)	
graph export "$outp\figures\Figure3.pdf", as(pdf) replace
restore
}

* h. Figure 4. Citizens participation perceptions and preferences (control group)
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
hist Gov_ListensCat if Treatment==0, color(gs11) lcolor(black) percent bin(4) addlabels xlabel(1.4 "Not at all" 2.2 "Not much" 3 "Much" 3.8 "Very much", labsize(small))  xtitle(" ") ylabel(,labsize(small)) ytitle("Percentage", size(small)) legend(order(1 "Control") size(vsmall)) title("How likely is it that the city government will listen to neighbors requests?", size(small)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=8 b=6)) name(Fig4A, replace)

hist Neighb_Decide if Treatment==0, color(gs11) lcolor(black) percent bin(3) addlabels xlabel(0.16 "Public Officials" 0.83 "Neighbors", labsize(small))  xtitle(" ") ylabel(0(20)80,labsize(small)) ytitle("Percentage", size(small)) legend(order(1 "Control") size(vsmall)) title("Who do you prefer to decide the investment projects to be carried out in your commune?", size(small)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=8 b=6)) name(Fig4B, replace)

grc1leg Fig4A Fig4B, legendfrom(Fig4A) c(2) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=5 b=5)) name(Fig4, replace)

graph display Fig4, xsize(20) ysize(12)
graph export "$outp\figures\Figure4.pdf", as(pdf) replace
}

* i. Figure 5. Heterogeneous effects on Perceptions of the Government - Perceived Quality of the Goverment, Collective action capacity and previous knowledge
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
use "$data/data.dta", clear
svyset idiso [pweight=w_es]

if 1==1{
foreach outcome in Gov_PCA Competence Benevolence Honesty{
	svy: reg STD_`outcome' i.T1##c.Gov_Q_C i.T2##c.Gov_Q_C $controls_unb $controls_rel i.Comuna
	margins, dydx(T2) at(Gov_Q_C=(1(1)10))
	marginsplot, plotopts(msym(i)) recastci(rline) ciopt(lp(dash)) yline(0) ytitle("d(`: variable label STD_`outcome'')/d(T2)", size(medsmall)) addplot(hist Gov_Q_C, percent yaxis(2) yscale(alt) lcolor(gs12%30) fcolor(gs12%30) ylabel(, labsize(medsmall) angle (0) axis(2)) xlabel(0 " " 1 "Very bad" 10 "Excellent" 11 " ", labsize(medsmall)) xtitle(, size(medsmall)) ytitle("% observations", size(medsmall) axis(2)) legend(order(2 "Estimate" 3 "% of people") size(vsmall))) title("`: variable label STD_`outcome''", size(medsmall)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) name(Fig5A`outcome', replace)
	
	svy: reg STD_`outcome' T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
	margins, dydx(T2) at(CollAction =(1(1)4))
	marginsplot, recast(scatter) yline(0) ytitle("d(`: variable label STD_`outcome'')/d(T2)", size(medsmall)) addplot(hist CollAction, percent yaxis(2) yscale(alt) lcolor(gs12%30) fcolor(gs12%30) ylabel(, labsize(medsmall) angle (0) axis(2)) ytitle("% of observations", size(medsmall) axis(2))) title("") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xlabel(1 "Not at all" 2 " " 3 " " 4 "Very" , labsize(medsmall)) xtitle(, size(medsmall)) legend(order(2 "Estimate" 3 "% of people")) name(Fig5B`outcome', replace)
	
	svy: reg STD_`outcome' T1##c.knows_bae1 T2##c.knows_bae1 $controls_unb $controls_rel2 i.Comuna
	margins, dydx(T2) at(knows_bae1=(1(1)4))
	marginsplot, recast(scatter) yline(0) ytitle("d(`: variable label STD_`outcome'')/d(T2)", size(medsmall)) addplot(hist knows_bae1, percent yaxis(2) yscale(alt) lcolor(gs12%30) fcolor(gs12%30) ylabel(, labsize(medsmall) angle (0) axis(2)) ytitle("% of observations", size(medsmall) axis(2))) title("") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xlabel(1 "Don't know" 2 " " 3 " " 4 "Knows both", labsize(medsmall)) xtitle(, size(medsmall)) legend(order(2 "Estimate" 3 "% of people")) name(Fig5C`outcome', replace)
}

grc1leg Fig5AGov_PCA Fig5ACompetence Fig5ABenevolence Fig5AHonesty Fig5BGov_PCA Fig5BCompetence Fig5BBenevolence Fig5BHonesty Fig5CGov_PCA Fig5CCompetence Fig5CBenevolence Fig5CHonesty, legendfrom(Fig5AGov_PCA) c(4) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=5 b=5)) title("Marginal effect of T2", size(vsmall)) name(Fig5, replace)
graph display Fig5, xsize(18) ysize(12)
graph export "$outp\figures\Figure5.pdf", as(pdf) replace
}

* j. Figure 6. Heterogeneous Effects on Trustworthiness of the City Government - Perceived Quality of the Government, collective action and previous knowledge
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
svy: reg zo_Gov_Trustworthy i.T1##c.Gov_Q_C i.T2##c.Gov_Q_C $controls_unb $controls_rel i.Comuna
margins, dydx(T2) at(Gov_Q_C=(1(1)10))
marginsplot, plotopts(msym(i)) recastci(rline) ciopt(lp(dash)) yline(0) ytitle("d(`: variable label STD_`outcome'')/d(T2)", size(medsmall)) addplot(hist Gov_Q_C, percent yaxis(2) yscale(alt) lcolor(gs12%30) fcolor(gs12%30) ylabel(, labsize(medsmall) angle (0) axis(2)) xlabel(0 " " 1 "Very bad" 10 "Excellent" 11 " ", labsize(medsmall)) xtitle(, size(medsmall)) ytitle("% observations", size(medsmall) axis(2)) legend(order(2 "Estimate" 3 "% of people") size(vsmall))) title("`: variable label STD_`outcome''", size(medsmall)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) name(Fig6A, replace)

svy: reg zo_Gov_Trustworthy T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
margins, dydx(T2) at(CollAction =(1(1)4))
marginsplot, recast(scatter) yline(0) ytitle("d(`: variable label STD_`outcome'')/d(T2)", size(medsmall)) addplot(hist CollAction, percent yaxis(2) yscale(alt) lcolor(gs12%30) fcolor(gs12%30) ylabel(, labsize(medsmall) angle (0) axis(2)) ytitle("% of observations", size(medsmall) axis(2))) title("") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xlabel(1 "Not at all" 2 " " 3 " " 4 "Very" , labsize(medsmall)) xtitle(, size(medsmall)) legend(order(2 "Estimate" 3 "% of people")) name(Fig6B, replace)

svy: reg zo_Gov_Trustworthy T1##c.knows_bae1 T2##c.knows_bae1 $controls_unb $controls_rel2 i.Comuna
margins, dydx(T2) at(knows_bae1=(1(1)4))
marginsplot, recast(scatter) yline(0) ytitle("d(`: variable label STD_`outcome'')/d(T2)", size(medsmall)) addplot(hist knows_bae1, percent yaxis(2) yscale(alt) lcolor(gs12%30) fcolor(gs12%30) ylabel(, labsize(medsmall) angle (0) axis(2)) ytitle("% of observations", size(medsmall) axis(2))) title("") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xlabel(1 "Don't know" 2 " " 3 " " 4 "Knows both", labsize(medsmall)) xtitle(, size(medsmall)) legend(order(2 "Estimate" 3 "% of people")) name(Fig6C, replace)

grc1leg Fig6A Fig6B Fig6C, legendfrom(Fig6A) c(3) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=5 b=5)) title("Marginal effect of T2", size(vsmall)) name(Fig6, replace)
graph display Fig6, xsize(18) ysize(10)
graph export "$outp\figures\Figure6.pdf", as(pdf) replace
}

}
graph close _all


*---------------------------------------*
* 2. APPENDIX							*
*---------------------------------------*

** A. TABLES AND GRAPHS
if 1==0{
* a. Figure A2. Recruitment timeline by treatment assignment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
graph bar T0 T1 T2, over(day, relabel(1 "6" 2 " " 3 " " 4 "9" 5 " " 6 " " 7 "12" 8 " " 9 " " 10 "15" 11 " " 12 " " 13 "18" 14 " " 15 " " 16 "21" 17 " " 18 " " 19 "24")) stack bar(1, color(gs4)) bar(2, color(gs8%60)) bar(3, color(cranberry%70)) legend(order(1 "Control" 2 "T1" 3 "T2") pos(6) r(1)) ytitle(Daily answers density by treatment assignment, size(small)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=8 b=6))
graph export "$outp\figures\FigureA2.pdf", as(pdf) replace
}

* b. Table A1. Multiple Hypothesis Testing results - Balance 
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==0{
cap texdoc close
	texdoc init "$results\TableA1", replace force
	tex {	
	tex \begin{table}[H]
	tex \centering
	tex \scriptsize		
	tex \caption{Balance - Multiple Hypotheses Testing \label{tab:balance_MHT}}
	tex \begin{adjustbox}{width=1.5\textwidth,center}
	tex \begin{tabular}{l*{13}{c}}			
	tex \toprule
	tex & Average & Control & T1 & T2 & OLS T1 & OLS T2 & RI1 & RI2 & WY1 & WY2 &BH1 & BH2 & Obs.\\	
	tex \midrule
	
loc i 0 
	foreach v in $balance{
	loc ++i 
	
	di in red "`v'"
			qui sum `v' 
			loc m`v'=string(r(mean), "%9.2f")
			loc s`v'=string(r(sd), "%9.3f")
			
			forvalues x=0(1)2 {
				qui sum `v' if Treatment==`x'
				loc m`x'`v' = string(r(mean), "%9.2f")
				loc s`x'`v' = string(r(sd), "%9.3f")
			}
			
			qui reg `v' T1 T2, vce(hc3)
			loc t1 = _b[T1]/_se[T1]
			loc p1`v' = string(2*ttail(e(df_r),abs(`t1')), "%9.3f")
			loc t2 = _b[T2]/_se[T2]
			loc p2`v' = string(2*ttail(e(df_r),abs(`t2')), "%9.3f")
			
			loc n`v'	: di %7.0f e(N)
		
			qui permute T1 difmeans=_b[T1], reps(1000) verbose nodots: reg `v' T1 T2, cl(Comuna)
			loc pval1`v' : di %7.3f r(p_upper)[1,1]
			
			qui permute T2 difmeans=_b[T2], reps(1000) verbose nodots: reg `v' T1 T2, cl(Comuna)
			loc pval2`v' : di %7.3f r(p_upper)[1,1]
			
			qui wyoung, cmd("regress `v' T1 T2, vce(hc3)") cluster(Comuna) familyp(T1) bootstraps(100) 
			loc pwy1`v' 	: di %7.3f r(table)[1,4]
			
			qui wyoung, cmd("regress `v' T1 T2, vce(hc3)") cluster(Comuna) familyp(T2) bootstraps(100) 
			loc pwy2`v' 	: di %7.3f r(table)[1,4]
			
			
			preserve 
			*loc v = "gender"
			qui parmby "regress `v' T1 T2, vce(hc3) ", label norestore
			qui multproc, puncor(0.05) method(simes) pvalue(p) rank(rank_) critical(p_crit) gpcor(corrected_p) reject(rejection) 
			
			format %7.3f p
			forval n = 1(1)2{
				loc pbenj`n'`v'=p_crit in `n'
				loc pbnj`n'`v' : di %7.3f `pbenj`n'`v''
				loc corr`n'`v'=corrected_p in `n'
				loc cor`n'`v' : di %7.3f `corr`n'`v''
				*di in red `pbnj`n'`v'' [`cor`n'`v'']
			}
			restore		

		tex \parbox[l]{5cm}{ `:variable label `v''} 	& `m`v'' & `m0`v'' 	& `m1`v'' & `m2`v'' 	& `p1`v'' & `p2`v'' & `pval1`v''  & `pval2`v'' 	& `pwy1`v'' & `pwy2`v'' & `pbnj1`v'' & `pbnj2`v'' & `n`v''\\
		tex                           				  	&  (`s`v'') 	& (`s0`v'')	& (`s1`v'') & (`s2`v'') & &  & & & & & [`cor1`v''] & [`cor2`v''] &  \\
		tex \addlinespace[2pt] 
	}
	tex \bottomrule
	tex \addlinespace[2pt]
	tex \multicolumn{14}{l}{\footnotesize{\begin{minipage}{1.9\textwidth}\textit{Notes:} Standard errors clustered by comuna are considered. All estimations use different inference or degrees of freedom correction methods to assess the significance of the difference in means between treated and control individuals. Column OLS presents the uncorrected p-value. RI contains the p-value from a randomization inference exercise with a thousand Montecarlo simulations of treatment assignment. WY presents the Westfall and Young (1993) multiple hypothesis testing adjusted p-value, while BH presents the Benjamini and Hochberg (1995) version of such adjustment. Column BM shows the Bell and McCaffrey (2002) method of degrees of freedom correction for inference in small samples, and column IK presents the Imbens and Koles\'ar (2016) correction method. Standard deviations are shown in parentheses and p critical values in brackets. \end{minipage}}} \\
	tex \end{tabular}
	tex \end{adjustbox}
	tex \end{table}
	tex }
	texdoc close	

}

* c. Table A2. Censored sample - Balance 
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
preserve 
keep if day<=21895 
cap texdoc close
	texdoc init "$results\TableA2", replace force
	tex \begin{table}[H]
	tex \centering
	tex \scriptsize
	tex \caption{Descriptive statistics and balance - Censored sample (even distribution of recruitment)\label{tab:Descriptives}}
	tex \begin{tabular}{l*{6}{c}}
	tex \toprule
	tex 					& Sample  & Control 		& \multicolumn{2}{c}{Diff wrt. Control}	& \multicolumn{1}{c}{Wald test} & Sample \\
	tex \textbf{Variable}  	& Average & (av. \& s.e.) & T1 	& T2 & T1=T2 & Size \\
	tex \midrule

	foreach v in $balance{
	disp in red "`v'"

		qui su `v'
		loc mean`v'	: di %7.3f r(mean)
		loc sd`v' 	: di %7.3f r(sd)

		qui reg `v' $Treatments, vce(hc3) 
		loc meT0`v'	: di %7.3f _b[_cons]
		loc seT0`v'	: di %7.3f _se[_cons]
		loc diT1`v' : di %7.3f _b[T1]
		loc seT1`v' : di %7.3f _se[T1]
		loc diT2`v' : di %7.3f _b[T2]
		loc seT2`v' : di %7.3f _se[T2]

		loc tbef1 = _b[T1]/_se[T1]
		loc pbef1 : di %7.3f 2*ttail(e(df_r),abs(`tbef1'))	
		loc staru1 = ""
		if ((`pbef1' < 0.1))  loc staru1 = "*" 
		if ((`pbef1' < 0.05)) loc staru1 = "**" 
		if ((`pbef1' < 0.01)) loc staru1 = "***" 
		
		loc tbef2 = _b[T2]/_se[T2]
		loc pbef2 : di %7.3f 2*ttail(e(df_r),abs(`tbef2'))	
		loc staru2 = ""
		if ((`pbef2' < 0.1))  loc staru2 = "*" 
		if ((`pbef2' < 0.05)) loc staru2 = "**" 
		if ((`pbef2' < 0.01)) loc staru2 = "***" 

		qui test T1=T2
		loc t1t2`v'	  : di %7.3f r(p)
		
		loc n`v' : di %7.0f e(N)
		
		tex \parbox[l]{4.3cm}{ `:variable label `v''} 	& `mean`v'' & `meT0`v'' 		& `diT1`v''`staru1' & `diT2`v''`staru2' 	& `t1t2`v'' 			& `n`v''\\
		tex  & [`sd`v''] &  (`seT0`v'') 		& (`seT1`v'')	& (`seT2`v'') 	 &			  & 	  \\
	}
	tex \addlinespace[2pt] 
	tex \bottomrule
	tex \addlinespace[2pt]
	tex \multicolumn{7}{c}{\footnotesize{\begin{minipage}{0.95\textwidth}\textit{Notes:} We truncate the sample to the days in which we observe an even distribution of observations recruited in each treatment condition. This assumes that people were assigned at random prior to establishing contact through the surveyor organization, and replacements began to be contacted from day 6 on. \end{minipage}}}
	tex \end{tabular}
	tex \end{table}
	texdoc close
restore
}

* d. Table A3. Descriptives Statistics of Dependent Variables (control group)
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
	cap texdoc close
	texdoc init "$results\TableA3", replace force
	tex {
	tex \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}		
	tex \begin{table}[H]
	tex \centering
	tex \scriptsize		
	tex \caption{Descriptive statistics of dependent variables - Control group\label{tab:desc_dependent}}
	tex \begin{tabular}{l*{5}{c}}			
	tex \toprule
	
	tex \textbf{Variable}  	&	\textbf{Obs.} & \textbf{Mean} & \textbf{SD} & \textbf{Min} & \textbf{Max} \\
	tex \midrule
	tex \addlinespace[2pt]
	tex \multicolumn{6}{l}{\textbf{Components of the Overall Perception of the Government}} \\
	tex \addlinespace[2pt]
	tex \hline
	foreach yvar in $perception{
		disp in red "`yvar'"
		
		qui {
		su `yvar' if T0==1, detail
			loc mean`yvar'	: di %7.3f r(mean) 
			loc sd`yvar'	: di %7.3f r(sd)
			loc min`yvar'	: di %7.1f r(min)
			loc max`yvar'	: di %7.1f r(max)
			loc n`yvar'		: di %7.0f r(N)	
		}
		
		tex \parbox[l]{5cm}{`:variable label `yvar'' } 	&  `n`yvar'' & `mean`yvar'' & `sd`yvar'' & `min`yvar'' & `max`yvar'' \\ 
	}
	
	tex \addlinespace[2pt]
	tex \hline
	tex \addlinespace[2pt]
	tex \multicolumn{6}{l}{\textbf{Dimensions of the Overall Perception of the Government}} \\
	tex \addlinespace[2pt]
	tex \hline
	
	foreach yvar in STD_Competence STD_Benevolence STD_Honesty STD_Gov_PCA{
		disp in red "`yvar'"
		
		qui {
		su `yvar' if T0==1, detail
			loc mean`yvar'	: di %7.3f r(mean) 
			loc sd`yvar'	: di %7.3f r(sd)
			loc min`yvar'	: di %7.1f r(min)
			loc max`yvar'	: di %7.1f r(max)
			loc n`yvar'		: di %7.0f r(N)			
		}

		tex \parbox[l]{5cm}{`:variable label `yvar'' } 	&  `n`yvar'' & `mean`yvar'' & `sd`yvar'' & `min`yvar'' & `max`yvar'' \\ 
	}
	tex \addlinespace[2pt]
	tex \hline
	tex \addlinespace[2pt]
	tex \multicolumn{6}{l}{\textbf{Trust in Institutions}} \\
	tex \addlinespace[2pt]
	tex \hline
	tex \multicolumn{6}{l}{\textit{Keep their promises/Care for the people}} \\
	
	foreach yvar in zo_Gov_Trustworthy $inst_trust{
		disp in red "`yvar'"
		
		qui {
		su `yvar' if T0==1, detail
			loc mean`yvar'	: di %7.3f r(mean) 
			loc sd`yvar'	: di %7.3f r(sd)
			loc min`yvar'	: di %7.1f r(min)
			loc max`yvar'	: di %7.1f r(max)
			loc n`yvar'		: di %7.0f r(N)	
		}
		
		tex \parbox[l]{5cm}{`:variable label `yvar'' } 	&  `n`yvar'' & `mean`yvar'' & `sd`yvar'' & `min`yvar'' & `max`yvar'' \\ 
	}	
	tex \addlinespace[2pt]
	tex \hline
	tex \addlinespace[2pt]
	tex \multicolumn{6}{l}{\textbf{Citizenry Participation}} \\
	tex \addlinespace[2pt]
	tex \hline
	foreach yvar in $participat{
		disp in red "`yvar'"
		
		qui {
		su `yvar' if T0==1, detail
			loc mean`yvar'	: di %7.3f r(mean) 
			loc sd`yvar'	: di %7.3f r(sd)
			loc min`yvar'	: di %7.1f r(min)
			loc max`yvar'	: di %7.1f r(max)
			loc n`yvar'		: di %7.0f r(N)	
		}
			
		tex \parbox[l]{5cm}{`:variable label `yvar'' } 	&  `n`yvar'' & `mean`yvar'' & `sd`yvar'' & `min`yvar'' & `max`yvar'' \\ 
		
	}	
	tex \bottomrule
	tex \addlinespace[2pt]
	tex \multicolumn{6}{l}{\footnotesize{\begin{minipage}{0.7\textwidth}\textit{Notes:} \end{minipage}}} \\
	tex \end{tabular}
	tex \end{table}
	tex }
	texdoc close	
}

* e. Table A4. Principal Component Analysis
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
glo zo_Competence "zo_Gov_Capable zo_Gov_Best zo_Gov_Budget"
glo zo_Benevolence "zo_Gov_Neigh zo_Gov_Helps zo_Gov_ICare"

pca $zo_Competence $zo_Benevolence zo_Gov_Honesty, vce(normal) level(95)

* Each dimension
foreach j in zo_Competence zo_Benevolence{
di in red "`j'"
	pca $`j', vce(normal) level(95)
}
}

* f. Table A5. Generalized Ordered Logit
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
set more off
if 1==0{
foreach i of global original{
	foreach outcome in 1 2 3 4 5 6 7{
		qui gologit2 `i' T1 T2 $controls_unb $controls_rel, autofit vce(robust)
		margins, dydx(T1 T2) predict(outcome(`outcome')) post vce(unconditional)
		sleep 1000
		est store `i'`outcome'
	}
}

global mathlab  "\%"
global math  "\$"
global tilde "\'"
global times "$\times$"


#delimit ;
global Notes "
{\begin{minipage}{\textwidth}
\small  
\vspace{0.2cm} 
\textit{Notes:} * p $math < $math 0.10, ** p $math < $math 0.05, *** p $math < $math 0.01.  Robust standard errors are shown in parenthesis. Control variables include: age, gender, socio-economic level, labor status, have know the `BA Elige' initiative previously, pre-treatment beliefs on government quality and the collective action dummy variable.
 \end{minipage}
 }
";
#delimit cr


foreach n of global original {
	#delimit ;
	esttab `n'1 `n'2 `n'3 `n'4 `n'5 `n'6 `n'7 ///
	using "$results\TableA5_`n'.tex",  replace label wrap varwidth(30) b(%5.3f) se(%5.3f) star(* 0.10 ** 0.05 *** 0.01) order(`t') refcat(`t' "\vspace{-6mm}", nolabel)  stats(N,  labels(`"Observations"', prefix(\addlinespace[3pt])) fmt( %10.0fc %10.3fc 0 0) ) addnote($Notes)  nonumber nonote compress noomitted nobaselevels
 ;
#delimit cr	
}

}

* g. Table A6. Estimated bounds following Oster (2019)
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
cap mat drop A
foreach v in STD_Gov_PCA STD_Competence STD_Benevolence STD_Honesty STD_Trustworthy zo_Gov_Trustworthy{
	qui reg `v' T1 T2 $controls_unb $controls_rel i.Comuna, vce(hc3)
	qui psacalc beta T2
	loc beta : di %7.3f r(beta)
	
	qui reg `v' T1 T2 $controls_unb $controls_rel i.Comuna, vce(hc3)
	qui psacalc delta T2
	loc delta : di %7.3f r(delta)
	
	mat define A = nullmat(A)\[`beta', `delta']
}		

matrix colnames A = beta delta

svmat A, n(col)
}



* h. Table A7. Main results controlling for unbalanced characteristics
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
reg STD_Gov_PCA T1 T2, vce(hc3)
test T1=T2 
loc p = r(p)
outreg2 using "$results\TableA7", replace tex keep(T1 T2) label addstat(Wald test, `p') addtext(Unbalanced controls, No, Political controls, No, Commune FE, No) dec(3) addnote("\scriptsize{\begin{minipage}{\textwidth} \textit{Notes:} Dependent variables from column (1) to (8) are constructed using a PCA method, and standardized with mean zero and standard deviation one. Column (9) depicts a normalized version of the trustworthiness direct measure between zero and one. The remaining columns depict dependent dummy variables. Columns (1) to (4) incorporate controls and commune fixed effects progressively. Columns (5) to (7) display the results by each dimension of the trust index. Columns (8) and (9) show results on a direct measure of trustworthiness, while columns (10) to (13) indirect measures of trust in members of the government. The last two columns show results over perceptions and preferences of participation. Control variables include those found unbalanced after treatment assignment and those directly related to the political perceptions, collective action capacity, importance of citizens participation in decision-making and previous knowledge of the initiative. Robust standard errors presented in parentheses *** p\textless 0.01, ** p\textless 0.05, * p\textless 0.1\end{minipage}}")

reg STD_Gov_PCA T1 T2 $controls_unb, vce(hc3)
test T1=T2 
loc p = r(p)

outreg2 using "$results\TableA7", append tex label addstat(Wald test, `p') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 ) addtext(Unbalanced controls, Yes, Political controls, No, Commune FE, No) dec(3)

reg STD_Gov_PCA T1 T2 $controls_unb $controls_rel, vce(hc3)
test T1=T2 
loc p = r(p)
outreg2 using "$results\TableA7", append tex label addstat(Wald test, `p') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, No) dec(3)

reg STD_Gov_PCA T1 T2 $controls_unb $controls_rel i.Comuna, vce(hc3)
test T1=T2 
loc p = r(p)
outreg2 using "$results\TableA7", append tex label addstat(Wald test, `p') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes) dec(3)

foreach outcome in STD_Competence STD_Benevolence STD_Honesty  STD_Trustworthy zo_Gov_Trustworthy P_Politicians_D C_Politicians_D P_Public_Servants_D C_Public_Servants_D Gov_Listens_D1 Neighb_Decide{
	reg `outcome' T1 T2 $controls_unb $controls_rel i.Comuna, vce(hc3)
	test T1=T2 
	loc p = r(p)
	outreg2 using "$results\TableA7", append tex label addstat(Wald test, `p') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes) dec(3)	
}
}

* i. Table A8. Main results using censored samples
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
qui reg STD_Gov_PCA T1 T2 $controls_unb $controls_rel i.Comuna if day<=21895 , vce(hc3)
qui test T1=T2 
loc p = r(p)
outreg2 using "$results\TableA8", replace tex keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) label addstat(Wald test, `p')addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes) dec(3) addnote("\scriptsize{\begin{minipage}{\textwidth} \textit{Notes:} Dependent variables from column (1) to (8) are constructed using a PCA method, and standardized with mean zero and standard deviation one. Column (9) depicts a normalized version of the trustworthiness direct measure between zero and one. The remaining columns depict dependent dummy variables. Columns (1) to (4) incorporate controls and commune fixed effects progressively. Columns (5) to (7) display the results by each dimension of the trust index. Columns (8) and (9) show results on a direct measure of trustworthiness, while columns (10) to (13) indirect measures of trust in members of the government. The last two columns show results over perceptions and preferences of participation. Control variables include those found unbalanced after treatment assignment and those directly related to the political perceptions, collective action capacity, importance of citizens participation in decision-making and previous knowledge of the initiative. Robust standard errors presented in parentheses *** p\textless 0.01, ** p\textless 0.05, * p\textless 0.1\end{minipage}}")

foreach outcome in STD_Competence STD_Benevolence STD_Honesty  STD_Trustworthy zo_Gov_Trustworthy P_Politicians_D C_Politicians_D P_Public_Servants_D C_Public_Servants_D Gov_Listens_D1 Neighb_Decide{
	qui reg `outcome' T1 T2 $controls_unb $controls_rel i.Comuna if day<=21895, vce(hc3)
	qui test T1=T2 
	loc p = r(p)
	outreg2 using "$results\TableA8", append tex label addstat(Wald test, `p') keep(T1 T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 5.knows_bae1 CollAction TrustOthers3cat Cit_Part Gov_Q_C) addtext(Unbalanced controls, Yes, Political controls, Yes, Commune FE, Yes) dec(3)
}
}

* j. Table A9. Perceived trustworthiness of different agents. 
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
glo 	dep_Prom_D "P_Politicians_D P_Public_Servants_D P_Family_D P_Neighbors_D"
glo	 	dep_Care_D "C_Politicians_D C_Public_Servants_D C_Family_D C_Neighbors_D"

foreach outcome in $dep_Prom_D $dep_Care_D{
	su `outcome' if Treatment==0
	loc mean`outcome' = r(mean)
	reg `outcome' T1 T2 $unbalanced_fund i.Comuna, vce (cluster Comuna)
	test T1=T2 
	loc p = r(p)
	outreg2 using "$results\TableA9", append tex label addstat(Control mean, `mean`outcome'', Wald test, `p') keep(T1 T2 Gov_Q_C CollAction Cit_Part) dec(3)
}
}
}

** B. HETEROGENEOUS EFFECTS
if 1==0{
* a. Figure B1. Correlation between previous knowledge of the program and perceived quality of the government 
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
preserve 
collapse (mean) Gov_Q_C knows_bae1, by(Comuna gender Treatment)
tw (lfit knows_bae1 Gov_Q_C if Treatment==0, lpattern(solid) lcolor(blue)) (scatter knows_bae1 Gov_Q_C if Treatment==0, mcolor(blue)) (lfit knows_bae1 Gov_Q_C if Treatment!=0, lpattern(solid) lcolor(red)) (scatter knows_bae1 Gov_Q_C if Treatment!=0, mlcolor(red) mfcolor(none) mlwidth(medthick)), legend(order(2 "Control" 4 "Treatment") size(vsmall) r(1)) xtitle("Perceived Quality of the Government", size(vsmall)) xlabel(, labsize(small)) ylabel(, labsize(small) angle(horizontal) format(%2.1f)) ytitle("Knowledge of the program", size(vsmall))  name(Quality_Knowledge, replace) title(" ", size(small)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white) margin(l=3 r=5 b=5)) 
graph export "$outp\figures\FigureB1.pdf", as(pdf) replace

restore
}

* b. Table B1. Heterogeneous effects on Perceptions about the government - perceived quality of the government, coll action and prev. knowledge
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
svy: reg STD_Gov_PCA T1##c.Gov_Q_C T2##c.Gov_Q_C $controls_unb $controls_rel i.Comuna
lincom 1.T2-1.T1
loc p = r(p)
outreg2 using "$results\TableB1", replace tex label addstat(Wald test, `p') keep(1.T1 1.T2 Gov_Q_C 1.T1#c.Gov_Q_C 1.T2#c.Gov_Q_C) dec(3)

foreach outcome in Competence Benevolence Honesty{
	svy: reg STD_`outcome' T1##c.Gov_Q_C T2##c.Gov_Q_C $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB1", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 Gov_Q_C 1.T1#c.Gov_Q_C 1.T2#c.Gov_Q_C) dec(3)
}

svy: reg STD_Gov_PCA T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
lincom 1.T2-1.T1
loc p = r(p)
outreg2 using "$results\TableB1", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 CollAction 1.T1#c.CollAction 1.T2#c.CollAction) dec(3)

foreach outcome in Competence Benevolence Honesty{
	svy: reg STD_`outcome' T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB1", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 CollAction 1.T1#c.CollAction 1.T2#c.CollAction) dec(3)
}
}

* c. Table B2. Heterogeneous effects on Trust in Institutional agents - perceived quality of the government, coll action and prev. knowledge
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
svy: reg zo_Gov_Trustworthy T1##c.Gov_Q_C T2##c.Gov_Q_C $controls_unb $controls_rel i.Comuna
lincom 1.T2-1.T1
loc p = r(p)
outreg2 using "$results\TableB2", replace tex label addstat(Wald test, `p') keep(1.T1 1.T2 1.T1#c.Gov_Q_C 1.T2#c.Gov_Q_C Gov_Q_C) dec(3)
	
foreach outcome in P_Politicians_D C_Politicians_D P_Public_Servants_D C_Public_Servants_D{
	svy: reg `outcome' T1##c.Gov_Q_C T2##c.Gov_Q_C $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB2", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 1.T1#c.Gov_Q_C 1.T2#c.Gov_Q_C Gov_Q_C) dec(3)
}	
	
svy: reg zo_Gov_Trustworthy T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
lincom 1.T2-1.T1
loc p = r(p)
outreg2 using "$results\TableB2", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 CollAction 1.T1#c.CollAction 1.T2#c.CollAction) dec(3)

foreach outcome in P_Politicians_D C_Politicians_D P_Public_Servants_D C_Public_Servants_D{
	svy: reg `outcome' T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB2", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 CollAction 1.T1#c.CollAction 1.T2#c.CollAction) dec(3)
}
}

* d. Table B3. Heterogeneous effects on Participation perceptions and preferences - perceived quality of the government, coll action and prev. knowledge
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
svy: reg Gov_Listens_D1 T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB3", replace tex label addstat(Wald test, `p') keep(1.T1 1.T2 1.T1##c.CollAction 1.T2##c.CollAction CollAction) dec(3)
	
svy: reg Neighb_Decide T1##c.CollAction T2##c.CollAction $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB3", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 1.T1##c.CollAction 1.T2##c.CollAction CollAction) dec(3)

svy: reg Gov_Listens_D1 T1##c.Cit_Part2 T2##c.Cit_Part2 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB3", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 1.T1##c.Cit_Part2 1.T2##c.Cit_Part2 Cit_Part2) dec(3)


svy: reg Neighb_Decide T1##c.Cit_Part2 T2##c.Cit_Part2 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB3", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 1.T1##c.Cit_Part2 1.T2##c.Cit_Part2 Cit_Part2) dec(3)
}
				
* e. Table B4. Heterogeneous effects of previous knowledge of the initiative
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
if 1==1{
svy: reg STD_Gov_PCA T1##i.knows_bae1 T2##i.knows_bae1 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
outreg2 using "$results\TableB4", replace tex label addstat(Wald test, `p') keep(1.T1 1.T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 1.T1#2.knows_bae1 1.T1#3.knows_bae1 1.T1#4.knows_bae1 1.T2#2.knows_bae1 1.T2#3.knows_bae1 1.T2#4.knows_bae1)  dec(3)

foreach outcome in Competence Benevolence Honesty{
	svy: reg STD_`outcome' T1##i.knows_bae1 T2##i.knows_bae1 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB4", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 1.T1#2.knows_bae1 1.T1#3.knows_bae1 1.T1#4.knows_bae1 1.T2#2.knows_bae1 1.T2#3.knows_bae1 1.T2#4.knows_bae1)  dec(3)
}

svy: reg zo_Gov_Trustworthy T1##i.knows_bae1 T2##i.knows_bae1 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB4", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 1.T1#2.knows_bae1 1.T1#3.knows_bae1 1.T1#4.knows_bae1 1.T2#2.knows_bae1 1.T2#3.knows_bae1 1.T2#4.knows_bae1) dec(3)
	
foreach outcome in P_Politicians_D C_Politicians_D P_Public_Servants_D C_Public_Servants_D{
	svy: reg `outcome' T1##i.knows_bae1 T2##i.knows_bae1 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB4", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 1.T1#2.knows_bae1 1.T1#3.knows_bae1 1.T1#4.knows_bae1 1.T2#2.knows_bae1 1.T2#3.knows_bae1 1.T2#4.knows_bae1) dec(3)
}	

svy: reg Gov_Listens_D1 T1##i.knows_bae1 T2##i.knows_bae1 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB4", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 1.T1#2.knows_bae1 1.T1#3.knows_bae1 1.T1#4.knows_bae1 1.T2#2.knows_bae1 1.T2#3.knows_bae1 1.T2#4.knows_bae1) dec(3)
	
svy: reg Neighb_Decide T1##i.knows_bae1 T2##i.knows_bae1 $controls_unb $controls_rel i.Comuna
	lincom 1.T2-1.T1
	loc p = r(p)
	outreg2 using "$results\TableB4", append tex label addstat(Wald test, `p') keep(1.T1 1.T2 2.knows_bae1 3.knows_bae1 4.knows_bae1 1.T1#2.knows_bae1 1.T1#3.knows_bae1 1.T1#4.knows_bae1 1.T2#2.knows_bae1 1.T2#3.knows_bae1 1.T2#4.knows_bae1) dec(3)
}
}

** C. POWER ESTIMATES

if 1==0{
cap texdoc close
	texdoc init Power_TrustIndexes, replace force
	tex \scriptsize		
	tex \begin{tabular}{l*{11}{c}}			
	tex \toprule
	tex & \multicolumn{4}{c}{Trust in the government - Indexes} & \multicolumn{7}{c}{Components} \\
	tex & Overall & Competence & Benevolence & Honesty & \multicolumn{3}{c}{Competence} & \multicolumn{3}{c}{Benevolence} & Honesty \\
	tex & \multicolumn{4}{c}{ } & Capable & Best & Budget & Neighbors & Helps need & Beneficial & Transparent \\
	tex & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) & (11) \\
	tex \midrule
	tex \addlinespace[1.5pt] 
	tex \multicolumn{12}{l}{\textit{Minimum Detectable Effect}}\\
	tex \addlinespace[1.5pt] 
	tex \hline
	tex \addlinespace[1.5pt] 

	glo l1 = ""
	glo l2 = ""
	glo l4 = ""
	glo l5 = ""
	glo l6 = ""
	glo l7 = ""
	glo l8 = ""
	
	loc i=0
	foreach v in $Trust_Indexes $Trust_Individ{
		loc ++i 
		disp in red "`v', `i'"
	
	*loc v="zo_Gov_Capable"
	*loc i=4

	qui su `v' if Treatment==0
	loc c_m :di %7.3f r(mean) 
	loc sdc :di %7.3f r(sd)
	loc obsc = r(N)
	
	forval n = 1(1)2{
		qui su `v' if T`n'!=. & (Treatment==`n' | Treatment==0)
		loc n0 = r(N)	
		
		qui su `v' if T`n'==1 & Treatment==`n'
		loc sdt_`n' = r(sd)
		loc obst = r(N)

		di in red "`c_m', `obsc', `obst', `sdc', `sdt_`n''"
		
		if `i'<=5{
			power twomeans `c_m', alpha(0.05) power(0.8) n1(`obsc') n2(`obst') direction(upper) sd1(`sdc') sd2(`sdt_`n'') knownsds
		loc rdd`n' :di %7.3f r(delta)
		}
		
		if `i'>5{
			power twoproportions `c_m', alpha(0.05) power(0.8) n1(`obsc') n2(`obst') direction(upper) continuity
			loc rdd`n' :di %7.3f r(delta)
		}
		
	}
	
	glo l1 = "$l1 & `rdd1'"
	glo l2 = "$l2 & `rdd2'"
	glo l4 = "$l4 & `c_m'"
	glo l5 = "$l5 & `sdc'"
	
	qui count if `v'!=. 
	loc nobs = r(N)
	
	forval n=0(1)3{
		qui count if `v'!=. & Treatment==`n'
		loc n`n' = r(N)
	}
	
	qui oneway `v' Treatment
	loc var_error`v' = r(rss)

	qui power oneway, alpha(0.05) varerror(`var_error`v'') n(`nobs') power(0.8) ngroups(3) grweights(`n0' `n1' `n2')
	loc Cdelta`v' :di %7.3f r(delta)
	loc BG_V`v' :di %7.1f r(Var_m)
	loc WG_V`v' :di %7.1f r(Var_e)
	loc Cohens`v' :di %7.3f sqrt(`BG_V`v''/`WG_V`v'')
	
	di in red "`Cdelta`v'', `Cohens`v''"
	
	glo l6 = "$l6 & `Cohens`v''"
	glo l7 = "$l7 & `BG_V`v''"
	glo l8 = "$l8 & `WG_V`v''"
	
	}	
	
	tex T1 					$l1 \\
	tex T2 					$l2 \\
	tex \addlinespace[1.5pt] 
	tex \hline 
	tex \addlinespace[1.5pt] 
	tex Control mean 		$l4 \\
	tex Control SD 			$l5 \\
	tex \addlinespace[1.5pt] 
	tex \hline 
	tex \addlinespace[1.5pt] 
	tex \textbf{Cohen's $\delta$} $l6 \\
	tex \addlinespace[1.5pt] 
	tex \hline 
	tex \addlinespace[1.5pt] 
	tex \multicolumn{14}{l}{\textit{Variances}}\\
	tex \addlinespace[1.5pt] 
	tex \hline 
	tex \addlinespace[1.5pt] 
	tex Between group 		$l7 \\
	tex Within group 		$l8 \\
	tex \bottomrule
	tex \addlinespace[2pt]
	tex \multicolumn{12}{l}{\footnotesize{\begin{minipage}{\textwidth}\textit{Notes:} All estimations of the Minimum Detectable Effect specify a comparison between the treated individuals and people from the control group in a pairwise fashion. Columns (4) to (11) incorporate a comparison of proportions given the binary nature of the dependent variable. This method uses normal approximation without continuity correction, following \cite{hemming2013menu}. We have 583 respondents in T1, 608 in T2, and 477 in the control group. Power is set to be 80\% and significance of the effect 5\%. Means and standard deviations of the control group are shown. Considering that the RCT design is multiarmed, we conduct power calculations considering the joint significance of the differences among treatment assignments. The Cohen's $\delta$ \citep{cohen2013statistical} provides a unitless measure of the magnitude of an effect with a lower bound of zero. $\delta$ is computed as the square root of the ratio between the group's means variance and the error variance; between and within-group variance, respectively. \end{minipage}}}
	tex \end{tabular}
	texdoc close	
}

glo Prom "P_Politicians_D P_Public_Servants_D"
glo Care "C_Politicians_D C_Public_Servants_D"
glo GovA "Gov_Listens_D1 Neighb_Decide"

if 1==1{
cap texdoc close
	texdoc init "$results\TableC1", replace force
	tex \begin{tabular}{l*{6}{c}}			
	tex \toprule
	tex & \multicolumn{2}{c}{Keep their promises} & \multicolumn{2}{c}{Care for the people} & \multicolumn{2}{c}{Citizens participation}  \\
	tex & Politicians & Public Servants & Politicians & Public Servants & Listens to & Citizens' \\
	tex & \multicolumn{4}{c}{ } & its neighbors & participation \\
	tex 					& (1) & (2) & (3) & (4) & (5) & (6) \\
	tex \midrule
	tex \addlinespace[1.5pt] 
	tex \multicolumn{7}{l}{\textit{Minimum Detectable Effect}}\\
	tex \addlinespace[1.5pt] 
	tex \hline
	tex \addlinespace[1.5pt] 

	glo l1 = ""
	glo l2 = ""
	glo l3 = ""
	glo l4 = ""
	glo l6 = ""
	glo l7 = ""
	glo l8 = ""
		
	foreach v in $Prom $Care $GovA{
	disp in red "`v'"

	qui su `v' if Treatment==0
	loc c_m :di %7.3f r(mean)
	loc obsc = r(N)
	
	forval n = 1(1)2{
		qui su `v' if T`n'!=. & (Treatment==`n' | Treatment==0)
		loc n0 = r(N)	
		
		qui su `v' if T`n'==1 & Treatment==`n'
		loc obst = r(N)

		power twoproportions `c_m', alpha(0.05) power(0.8) n1(`obsc') n2(`obst') direction(upper)
		loc rdd`n' :di %7.3f r(delta)
	}
	
	glo l1 = "$l1 & `rdd1'"
	glo l2 = "$l2 & `rdd2'"
	glo l4 = "$l4 & `c_m'"
	
	qui count if `v'!=. 
	loc nobs = r(N)
	
	forval n=0(1)3{
		qui count if `v'!=. & Treatment==`n'
		loc n`n' = r(N)
	}
	
	qui oneway `v' Treatment
	loc var_error`v' = r(rss)

	power oneway, alpha(0.05) varerror(`var_error`v'') n(`nobs') power(0.8) ngroups(3) grweights(`n0' `n1' `n2')
	loc Cdelta`v' :di %7.3f r(delta)
	loc BG_V`v' :di %7.1f r(Var_m)
	loc WG_V`v' :di %7.1f r(Var_e)
	loc Cohens`v' :di %7.3f sqrt(`BG_V`v''/`WG_V`v'')
	
	di in red "`Cdelta`v'', `Cohens`v''"
	
	glo l6 = "$l6 & `Cohens`v''"
	glo l7 = "$l7 & `BG_V`v''"
	glo l8 = "$l8 & `WG_V`v''"
	
	}	
	
	tex T1 					$l1 \\
	tex T2 					$l2 \\
	tex \addlinespace[2pt] 
	tex \hline 
	tex \addlinespace[2pt] 
	tex Control mean 		$l4 \\
	tex \addlinespace[2pt] 
	tex \hline 
	tex \addlinespace[2pt] 
	tex \textbf{Cohen's $\delta$} $l6 \\
	tex \addlinespace[2pt] 
	tex \hline 
	tex \addlinespace[2pt] 
	tex \multicolumn{7}{l}{\textit{Variances}}\\
	tex \addlinespace[2pt] 
	tex \hline 
	tex \addlinespace[2pt] 
	tex Between group 		$l7 \\
	tex Within group 		$l8 \\
	tex \bottomrule
	tex \addlinespace[2pt]
	tex \multicolumn{7}{l}{\footnotesize{\begin{minipage}{0.68\textwidth}\textit{Notes:} All estimations of the Minimum Detectable Effect specify a comparison of proportions between the treated individuals and people from the control group in a pairwise fashion, given the binary nature of the dependent variable. This method uses normal approximation without continuity correction, following \citet{hemming2013menu}. We have 583 respondents in T1, 608 in T2 and 477 in the control group. Power is set to be 80\% and significance of the effect 5\%. Means of the control group are shown. Considering that the RCT design is multiarmed, we conduct power calculations considering the joint significance of the differences among treatment assignments. The Cohen's $\delta$ \citep{cohen2013statistical} provides a unitless measure of the magnitude of an effect with a lower bound of zero. $\delta$ is computed as the square root of the ratio between the group's means variance and the error variance; between and within-group variance, respectively. \end{minipage}}}
	tex \end{tabular}
	texdoc close
}



